package com.example.demo.设计模式.代理模式.CGLIB代理;

import net.sf.cglib.proxy.Enhancer;

public class Test {
    public static void main(String[] args) {
        RealSubject realSubject = new RealSubject();
        ProxyHandler proxyHandler = new ProxyHandler();

        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(realSubject.getClass());
        enhancer.setCallback(proxyHandler);

        RealSubject proxy = (RealSubject) enhancer.create();
        proxy.doSomething();
    }
}
